#include "tinyxml.h"
#include "stdafx.h"

#include "collada.h"

#ifdef _DEBUG
#define DEBUG_NEW new( _NORMAL_BLOCK, __FILE__, __LINE__ )
#define new DEBUG_NEW
#endif

using namespace Collada;

Collada::Data* Collada::LoadFromFile( const std::string& path )
{
	// tinyxml
	// http://www.grinninglizard.com/tinyxmldocs/index.html

	TiXmlDocument doc;
	doc.LoadFile( path.c_str() );

	return ( Data* )Data::Create( "", path.c_str(), NULL, doc.FirstChildElement() );

}

Collada::PrimitiveType Collada::StrToPrimitiveType( const std::string& str )
{
	if( str == "lines" )
	{
		return COLLADA_PT_LINES;
	}

	if( str == "linestrips" )
	{
		return COLLADA_PT_LINESTRIPS;
	}

	if( str == "polygons" )
	{
		return COLLADA_PT_POLYGONS;
	}

	return 0;
}

Collada::Semantic Collada::StrToSemantic( const std::string& str )
{
	if( str == "POSITION" )
	{
		return COLLADA_SEMANTIC_POSITION;
	}
	if( str == "NORMAL" )
	{
		return COLLADA_SEMANTIC_NORMAL;
	}
	if( str == "TEXCOORD" )
	{
		return COLLADA_SEMANTIC_TEXCOORD;
	}

	return 0;
}

Collada::Type Collada::StrToType( const std::string& str )
{
	if( str == "bool" )
	{
		return COLLADA_TYPE_BOOL;
	}

	if( str == "float" )
	{
		return COLLADA_TYPE_FLOAT;
	}

	if( str == "int" )
	{
		return COLLADA_TYPE_INT;
	}

	return 0;
}